<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/inc/common.jsp"%>
<html>
<head>
<title>申报管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<script type="text/javascript">
	$(function() {
		initDg();//初始化datagrid
		////setDgBut(0,0);//初始化datagrid按钮
	});
	
	//回车查询
	$(document).keydown(function(e){
		if(e.keyCode == 13) {
			searchDate();
		}
	});
	
	//初始化数据列表
	function initDg(){
		$('#dg').datagrid({
			url:'${basePath}/bus/carArchives/query.do',
			loadMsg:'数据装载中......',
		    title:'结果列表',//标题
		    width:'auto',//列表的宽度
			height:'auto',//列表的高度
			fit:true,//自动填充全屏
			nowrap: false,//数据是否显示在一行中
			fitColumns:true,//是否根据字体数收缩
		    pagination:true,//分页底部显示
		    pageList:[10,20,50],//设置分页下拉页数
		    rownumbers : true,//显示行号
			//singleSelect:true,//只能单选
			autoRowHeight:false,//自动行高
			idField : 'ID',
		    columns:[[
				{field:'ck',checkbox:'true'},
				{field:'car_no',title:'车牌号',width:fixWidth(8),align:'center'},
				{field:'archive_no',title:'车辆备案号',width:fixWidth(11),align:'center'},
				{field:'serial_no',title:'流水号',width:fixWidth(11),align:'center'},
				{field:'car_nationality',title:'国籍',width:fixWidth(5),align:'center',
					formatter:function(value,row,index){
		                return parent.formartDic(value,"1005");
		            }
				},
				{field:'car_owner',title:'车主',width:fixWidth(8),align:'center'},
				{field:'car_use_type',title:'车辆性质',width:fixWidth(6),align:'center',
					formatter:function(value,row,index){
		                return parent.formartDic(value,"1009");
		            }
				},
				{field:'vehicle_import_id',title:'状态',width:fixWidth(12),align:'center',
					formatter:function(value,row,index){
						return showCustomState(row.ARCHIVE_NO);
					}
				},
				{field:'begin_date',title:'生效日期',width:fixWidth(8),align:'center',
					formatter:function(value,row,index){
						return changeDateToString(value);
					}
				},
				{field:'end_date',title:'失效日期',width:fixWidth(8),align:'center',
					formatter:function(value,row,index){
						return changeDateToString(value);
					}
				},
				{field:'create_time',title:'备案日期',width:fixWidth(8),align:'center',
					formatter:function(value,row,index){
						return changeDateToString(value);
					}
				},
				{field:'name',title:'备案机构',width:fixWidth(16),align:'center'}
			]],
			toolbar:[
				{
					id : 'dg-add',
					text : '新增',
					iconCls : 'icon-add',
					handler : function() {
						editData();
					}
				},'-',{
					id : 'dg-edit',
					text : '修改',
					iconCls : 'icon-edit',
					handler : function() {
						var row = $('#dg').datagrid('getSelected');
						if (row) {
							editData(row.ID);
						}else{
							$.messager.alert('消息', "请选择一条信息!",'info');	
						}
					}
				},'-',{
					id : 'dg-edit-print',
					text : '打印预览',
					iconCls : 'icon-car_add',
					handler : function() {
						doPrint();
					}
				}		
		   	],
            onSelect: function (index, row) {
            	//setDgBut(1,1);//设置单选的按钮状态
            },
            onUnselect: function (index, row) {
            	////setDgBut(2,1);//设置取消单选的按钮状态
            },
            onSelectAll: function (index, row) {
            	//setDgBut(3,index.length);//设置全选的按钮状态
            },
            onUnselectAll: function (index, row) {
            	//setDgBut(2,index.length);//设置取消全选的按钮状态
            }
		});
	}
	
	//查询
	function searchDate(){
		var params = $('#dg').datagrid('options').queryParams; //先取得 datagrid 的查询参数
        var fields =$('#searchForm').serializeArray(); //自动序列化表单元素为JSON对象  
        $.each( fields, function(i, field){
            params[field.name] = field.value; //设置查询参数  
        });
        $('#dg').datagrid('reload'); //设置好查询参数 reload 一下就可以了 
	}
	
	//打印
	function doPrint() {
		window.location.href='../../business/demo/demoPrint.jsp';
	}
	
	//编辑
	function editData(id){
		if(id != null && id != "undefined" && id != ""){
			window.location.href="${basePath}/bus/carArchives/edit.do?id="+id;
		}else{
			window.location.href="${basePath}/bus/carArchives/edit.do";
		}
	}
	
	//清空
	function cleanDate(){
		$('#searchForm').form('clear');
	}

</script>
<body>
	<div class="easyui-layout" fit="true">
			<div data-options="region:'north', title:'查询条件',split:true,collapsed:false,footer:'#searchfooter'" style="overflow: hidden;">
			<!-- 查询条件 -->
			<div style="padding:10px 5px 45px 20px;">
			<form id="searchForm" name="searchForm" style="margin-bottom: 0px;">
					<table class="search-table"  width="80%" cellpadding="0" cellspacing="0" border="0">
						<tr>
							<td align="right" width="10%">车牌号:</td>
							<td width="15%">
								<input class="easyui-textbox" type="text" id="carNo" name="carNo"></input>
							</td>
							<td align="right" width="10%">车辆备案号:</td>
								<td width="40%">
								<input class="easyui-textbox" type="text" id="archiveNo" name="archiveNo"></input>
							</td>
						</tr>
					</table>
				</form>
			</div>
			<!-- 搜索按钮 -->
			<div id="searchfooter" style="text-align:right;padding: 0px 10px">
				<a href="javascript:void(0)" class="easyui-linkbutton" onclick="searchDate()"  data-options="iconCls:'icon-search',plain:true" >查询</a>
				<span class="search-btn-separator"></span>
				<a href="javascript:void(0)" class="easyui-linkbutton" onclick="cleanDate()" data-options="iconCls:'icon-cross',plain:true">重置</a>
			</div>
		</div>
		<!-- 数据列表 -->
		<div region="center" split="true" border="false" style="overflow: hidden;width: 99%;height: auto">
			<table id="dg"></table>
		</div>
	</div>
</body>
</html>
